package arrays

type Repeator interface {
	Len() int
	IsRepeat(n int, v interface{}) bool
}

type StringSlice []string

func (s StringSlice) Len() int { return len(s) }
func (s StringSlice) IsRepeat(n int, v interface{}) bool { return s[n] == v.(string) }
func (s StringSlice) In(v string) bool {return In(v, s)}
func StringIn(v string, s []string) bool { return In(v, StringSlice(s)) }

type IntSlice []int

func (s IntSlice) Len() int { return len(s) }
func (s IntSlice) IsRepeat(n int, v interface{}) bool { return s[n] == v.(int) }
func (s IntSlice) In(v string) bool {return In(v, s)}
func IntIn(v int, s []int) bool { return In(v, IntSlice(s)) }

func In(v interface{}, data Repeator) bool {
	for i := 0; i < data.Len(); i++ {
		if data.IsRepeat(i, v) {
			return true
		}
	}

	return false
}
